package com.tt.dp.compound.decorator;

import com.tt.dp.compound.model.Quackable;
import com.tt.dp.compound.observer.Observer;

/**
 * 计数器(装饰者模式)
 */
public class QuackCounter implements Quackable {


    private Quackable duck;

    private static int numberOfQuack;

    public QuackCounter(Quackable duck) {
        this.duck = duck;
    }

    public void quack() {
        this.duck.quack();
        numberOfQuack ++;
    }

    public static int getQuacks() {
        return numberOfQuack;
    }

    public void registerObserver(Observer observer) {
        this.duck.registerObserver(observer);
    }

    public void notifyObservers() {
        this.duck.notifyObservers();
    }
}
